package com.cpo.validators;

import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.cpo.domain.User;

@Component("loginValidator")
public class LoginValidator implements Validator {

	@SuppressWarnings("unchecked")
	public boolean supports(Class clazz) {
		
		return User.class.isAssignableFrom(clazz);
	}

	public void validate(Object model, Errors errors) {
		ValidationUtils.rejectIfEmpty(errors, "userName", "required.userName", "User Name is required");
		ValidationUtils.rejectIfEmpty(errors, "password", "required.password", "Password is required");
		
		
	}

}
